home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / MODULE.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  39KB  |  1,347 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.26  $
  6. //
  7. // Definition of class TModule.  TModule defines the basic behavior for OWL
  8. // libraries and applications.
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_MODULE_H)
  11. #define OWL_MODULE_H
  12.  
  13. #if !defined(OWL_DEFS_H)
  14. # include <owl/defs.h>
  15. #endif
  16. #if !defined(CLASSLIB_OBJSTRM_H)
  17. # include <classlib/objstrm.h>
  18. #endif
  19. #if !defined(OWL_EXCEPT_H)
  20. # include <owl/except.h>
  21. #endif
  22. #if !defined(CLASSLIB_POINTER_H)
  23. # include <classlib/pointer.h>
  24. #endif
  25.  
  26. #if defined(BI_NAMESPACE)
  27. namespace OWL {
  28. #endif
  29.  
  30. // Generic definitions/compiler options (eg. alignment) preceeding the
  31. // definition of classes
  32. #include <services/preclass.h>
  33.  
  34. // TModuleVersionInfo needs FILETIME defined, which may not be seen for
  35. // 16-bit apps - It is defined in COMPOBJ.H
  36. //
  37. #if defined(BI_PLAT_WIN16)
  38. # if !defined(_FILETIME_)
  39.     struct far tagFILETIME {uint32 dwLowDateTime; uint32 dwHighDateTime;};
  40.     typedef tagFILETIME FILETIME;
  41. #   define _FILETIME_
  42. # endif
  43. #endif
  44.  
  45. // These DLL name strings are used in INITDLL.CPP and MODULE.CPP
  46. // for locking DLLs in memory
  47. //
  48. #if defined(_OWLDLL) && !defined(BI_PLAT_WIN32)
  49. # if !defined(BIDS_DLLNAME)
  50. #   if defined(__TRACE) || defined(__WARN)
  51. #     define BIDS_DLLNAME "BDS52D"
  52. #   else
  53. #     define BIDS_DLLNAME "BDS52"
  54. #   endif
  55. # endif
  56. # if !defined(OWL_DLLNAME)
  57. #   if defined(__TRACE) || defined(__WARN)
  58. #     define OWL_DLLNAME "OWL52D"
  59. #   else
  60. #     define OWL_DLLNAME "OWL52"
  61. #   endif
  62. # endif
  63. #endif
  64.  
  65. class _OWLCLASS TWindow;
  66. class _OWLCLASS TDialog;
  67. class _OWLCLASS_RTL TXInvalidModule;
  68.  
  69. //
  70. // class TModule
  71. // ~~~~~ ~~~~~~~
  72. class _OWLCLASS TModule : public TStreamableBase {
  73.   public:
  74.     // Class scoped types
  75.     //
  76.     typedef HINSTANCE THandle;  // TModule encapsulates an HINSTANCE
  77.  
  78.     // Constructors & destructor
  79.     //
  80.     TModule(const char far* name, bool shouldLoad = true, bool mustLoad = true);
  81.     TModule(const char far* name, THandle handle);
  82.     TModule(const char far* name, THandle handle, const char far* cmdLine);
  83.     virtual ~TModule();
  84.  
  85.     // Finish-up initialization of a module
  86.     //
  87.     void          InitModule(THandle handle, const char far* cmdLine);
  88.  
  89.     // Get & set members. Use these instead of directly accessing members
  90.     //
  91.     const char far* GetName() const;
  92.     void          SetName(const char far* name);
  93.  
  94.     THandle       GetHandle() const;      // Get the module instance handle
  95.     operator      THandle() const;
  96.     bool operator ==(const TModule& m) const;
  97.     bool          IsLoaded() const;
  98.  
  99.     // Module wide error handler. Called when fatal exceptions are caught.
  100.     //
  101.     virtual int   Error(xmsg& x, uint captionResId, uint promptResId=0);
  102.  
  103.     // Windows HINSTANCE/HMODULE related API functions encapsulated
  104.     //
  105.     int           GetModuleFileName(char far* buff, int maxChars);
  106.  
  107.     FARPROC       GetProcAddress(const char far* fcnName) const;
  108.  
  109. #if defined(BI_PLAT_WIN16)
  110.     int           GetModuleUsage() const;
  111.     int           GetInstanceData(void NEAR* data, int len) const;
  112. #endif
  113.  
  114.     HRSRC         FindResource(TResId id, const char far* type) const;
  115.     HGLOBAL       LoadResource(HRSRC hRsrc) const;
  116.     uint32        SizeofResource(HRSRC hRsrc) const;
  117.  
  118. #if defined(BI_PLAT_WIN16)
  119.     int           AccessResource(HRSRC hRsrc) const;
  120.     HGLOBAL       AllocResource(HRSRC hRsrc, uint32 size) const;
  121.     RSRCHDLRPROC  SetResourceHandler(const char far* type, RSRCHDLRPROC loadProc) const;
  122. #endif
  123.  
  124.     int           LoadString(uint id, char far* buf, int maxChars) const;
  125.     string        LoadString(uint id) const;
  126.     HBITMAP       LoadBitmap(TResId id) const;
  127.     bool          GetClassInfo(const char far* name, WNDCLASS far* wndclass) const;
  128.     HACCEL        LoadAccelerators(TResId id) const;
  129.     HMENU         LoadMenu(TResId id) const;
  130.     HCURSOR       LoadCursor(TResId id) const;
  131.     HICON         LoadIcon(const char far* name) const;
  132.  
  133. #if defined(BI_PLAT_WIN16)
  134.     HCURSOR       CopyCursor(HCURSOR hCursor) const;
  135. #endif
  136.  
  137.     HICON         CopyIcon(HICON hIcon) const;
  138.  
  139.   protected:
  140.     void          SetHandle(THandle handle);  // Set the module instance handle
  141.  
  142.   protected_data:
  143.     char*         Name;       // Name of the module
  144.     union {
  145. #if defined(OWL2_COMPAT)
  146.       THandle     HInstance;  // Old 2.x name
  147. #endif
  148.       THandle     Handle;     // New name
  149.     };
  150.  
  151.   private:
  152.     bool          ShouldFree; // Should free the module when done?
  153.  
  154.     // Hidden to prevent accidental copying or assignment
  155.     //
  156.     TModule(const TModule&);
  157.     TModule& operator =(const TModule&);
  158.  
  159. #if defined(OWL2_COMPAT)
  160.   // Obsolete members for Owl 2.x compatibility
  161.   //
  162.   public:
  163.     THandle       GetInstance() const;
  164.     void          SetInstance(THandle handle);
  165.     typedef ::TXInvalidModule TXInvalidModule;  // Exceptions moved to global scope
  166. #endif
  167. #if defined(OWL1_COMPAT)
  168.   // Obsolete members for Owl 1 compatibility
  169.   //
  170.   public:
  171.     char far* lpCmdLine;    // Use argv & argc for portability
  172.     TStatus   Status;       // Use exceptions
  173.  
  174.     TWindow*  ValidWindow(TWindow* win);
  175.     TWindow*  MakeWindow(TWindow* win);
  176.     int       ExecDialog(TDialog* dialog);
  177.  
  178.     virtual void  Error(int errorCode);
  179.  
  180.     HWND      GetClientHandle(HWND hWnd);
  181.     TWindow*  GetParentObject(HWND hWndParent);
  182.  
  183.     bool      LowMemory();
  184.     void      RestoreMemory();
  185. #endif
  186.  
  187.   friend ostream& _OWLFUNC operator <<(ostream& os, const TModule& m);
  188.   DECLARE_STREAMABLE(_OWLCLASS, TModule, 1);
  189. };
  190.  
  191. //
  192. // Bring in the system's version info header if not already included
  193. //
  194. #if defined(BI_PLAT_WIN16) && !defined(VS_FILE_INFO)
  195. # include <ver.h>  // struct VS_FIXEDFILEINFO;
  196. #endif
  197.  
  198. //
  199. // class TModuleVersionInfo
  200. // ~~~~~ ~~~~~~~~~~~~~~~~~~
  201. // Access to a TModule's VERSIONINFO resource.
  202. //
  203. class _OWLCLASS TModuleVersionInfo {
  204.   public:
  205.     // TFileOS values are returned by GetFileOS()
  206.     enum TFileOS { OSUnknown    = VOS_UNKNOWN,
  207.                    DOS          = VOS_DOS,
  208.                    OS216        = VOS_OS216,
  209.                    OS232        = VOS_OS232,
  210.                    NT           = VOS_NT,
  211.                    Windows16    = VOS__WINDOWS16,
  212.                    PM16         = VOS__PM16,
  213.                    PM32         = VOS__PM32,
  214.                    Windows32    = VOS__WINDOWS32,
  215.                    DosWindows16 = VOS_DOS_WINDOWS16,
  216.                    DosWindows32 = VOS_DOS_WINDOWS32,
  217.                    OS216PM16    = VOS_OS216_PM16,
  218.                    OS232PM32    = VOS_OS232_PM32,
  219.                    NTWindows32  = VOS_NT_WINDOWS32
  220.     };
  221.     // TFileType is returned by GetFileType()
  222.     enum TFileType { TypeUnknown = VFT_UNKNOWN,
  223.                      App         = VFT_APP,
  224.                      DLL         = VFT_DLL,
  225.                      DevDriver   = VFT_DRV,
  226.                      Font        = VFT_FONT,
  227.                      VirtDevice  = VFT_VXD,
  228.                      StaticLib   = VFT_STATIC_LIB
  229.     };
  230.     // TFileSubType values are returned by GetFileSubType() if GetFileType
  231.     // returned DevDriver or Font
  232.     enum TFileSubType { UnknownDevDriver,  //VFT2_UNKNOWN
  233.                         PtrDriver,         //VFT2_DRV_PRINTER
  234.                         KybdDriver,        //VFT2_DRV_KEYBOARD
  235.                         LangDriver,        //VFT2_DRV_LANGUAGE
  236.                         DisplayDriver,     //VFT2_DRV_DISPLAY
  237.                         MouseDriver,       //VFT2_DRV_MOUSE
  238.                         NtwkDriver,        //VFT2_DRV_NETWORK
  239.                         SysDriver,         //VFT2_DRV_SYSTEM
  240.                         InstallableDriver, //VFT2_DRV_INSTALLABLE
  241.                         SoundDriver,       //VFT2_DRV_SOUND
  242.                         UnknownFont,       //VFT2_UNKNOWN
  243.                         RasterFont,        //VFT2_FONT_RASTER
  244.                         VectorFont,        //VFT2_FONT_VECTOR
  245.                         TrueTypeFont       //VFT2_FONT_TRUETYPE
  246.     };
  247.     TModuleVersionInfo(TModule::THandle module);
  248.     TModuleVersionInfo(const char far* modFName);
  249.    ~TModuleVersionInfo();
  250.  
  251.     VS_FIXEDFILEINFO far& GetFixedInfo();
  252.  
  253.     uint32    GetSignature() const;
  254.     uint32    GetStrucVersion() const;
  255.     uint32    GetFileVersionMS() const;
  256.     uint32    GetFileVersionLS() const;
  257.     uint32    GetProductVersionMS() const;
  258.     uint32    GetProductVersionLS() const;
  259.     bool      IsFileFlagSet(uint32 flag) const;
  260.     uint32    GetFileFlagsMask() const;
  261.     uint32    GetFileFlags() const;
  262.     bool      IsDebug() const;
  263.     bool      InfoInferred() const;
  264.     bool      IsPatched() const;
  265.     bool      IsPreRelease() const;
  266.     bool      IsPrivateBuild() const;
  267.     bool      IsSpecialBuild() const;
  268.     uint32    GetFileOS() const;  // returns TFileOS values
  269.     TFileType GetFileType() const;
  270.     uint32    GetFileSubType() const;
  271.     FILETIME  GetFileDate() const;
  272.  
  273.     bool GetInfoString(const char far* str, const char far*& value, uint lang=0);
  274.  
  275.     bool GetFileDescription(const char far*& fileDesc, uint lang=0);
  276.     bool GetFileVersion(const char far*& fileVersion, uint lang=0);
  277.     bool GetInternalName(const char far*& internalName, uint lang=0);
  278.     bool GetLegalCopyright(const char far*& copyright, uint lang=0);
  279.     bool GetOriginalFilename(const char far*& originalFilename, uint lang=0);
  280.     bool GetProductName(const char far*& prodName, uint lang=0);
  281.     bool GetProductVersion(const char far*& prodVersion, uint lang=0);
  282.     bool GetSpecialBuild(const char far*& debug, uint lang=0);
  283.  
  284.     uint   GetLanguage() const;
  285.     string GetLanguageName() const;
  286.  
  287.     static string GetLanguageName(uint language);
  288.  
  289.   protected:
  290.     bool Init(const char far* modFName);
  291.  
  292.     void far*         Buff;           // new'd File version info buffer
  293.     uint32            Lang;           // Default language translation
  294.     VS_FIXEDFILEINFO far* FixedInfo;  // Fixed file info structure
  295.  
  296.   private:
  297.     // Don't allow this object to be copied.
  298.     //
  299.     TModuleVersionInfo(const TModuleVersionInfo&);
  300.     TModuleVersionInfo& operator =(const TModuleVersionInfo&);
  301. };
  302.  
  303. //
  304. // class TXInvalidModule
  305. // ~~~~~ ~~~~~~~~~~~~~~~
  306. class _OWLCLASS_RTL TXInvalidModule : public TXOwl {
  307.   public:
  308.     TXInvalidModule(const char far* name = 0);
  309.  
  310. #if defined(BI_NO_COVAR_RET)
  311.     TXBase* Clone();
  312. #else
  313.     TXInvalidModule* Clone();
  314. #endif
  315.     void Throw();
  316.  
  317.     static void Raise(const char far* name = 0);
  318. };
  319.  
  320. //
  321. // class TErrorMode
  322. // ~~~~~ ~~~~~~~~~~
  323. // Simple encapsulation of the SetErrorMode call. Manages putting the error
  324. // mode back to its previous state on destruction, thus is exception safe.
  325. //
  326. class TErrorMode {
  327.   public:
  328.     TErrorMode(uint mode);
  329.    ~TErrorMode();
  330.  
  331.   private:
  332.     uint PrevMode;
  333. };
  334.  
  335. //----------------------------------------------------------------------------
  336. // Global variable and functions
  337.  
  338. //
  339. // Global pointer to the current module. One must be available in each linked
  340. // DLL or EXE.
  341. //
  342. extern TModule* Module;
  343.  
  344. //
  345. // Exported pointers from OWL modules, implemented in GLOBAL.CPP
  346. // Unmanagled to allow easy loading via LoadLibrary
  347. //
  348. class _OWLCLASS TDocTemplate;
  349. extern "C" {
  350.   TDocTemplate** PASCAL GetDocTemplateHead(int version);
  351.   TModule** PASCAL GetModulePtr(int version);
  352. }
  353.  
  354. #if defined(BI_NAMESPACE)
  355. } // namespace OWL
  356. #endif
  357.  
  358. //
  359. // Main entry point for an Owl application
  360. //
  361. int OwlMain(int argc, char* argv[]);
  362.  
  363.  
  364. extern "C" {
  365.  
  366. //
  367. // Initialization routine that must be called from User DLL if DLL
  368. // provides it's own entry point [i.e. LibMain or DllEntryPoint]
  369. //
  370. bool OWLInitUserDLL(HINSTANCE hInstance, LPSTR cmdLine);
  371. }
  372.  
  373.  
  374. #if defined(BI_NAMESPACE)
  375. namespace OWL {
  376. #endif
  377.  
  378.  
  379. //----------------------------------------------------------------------------
  380. // Definition of TDllLoader template, and TModuleProc class & derived
  381. // templates. TDllLoader<> provides an easy way to load one instance of a dll
  382. // on demand.
  383. // TModuleProcX<>s provide dynamic binding & call access to exported module
  384. // procs
  385. //
  386.  
  387. //
  388. // class TDllLoader<>
  389. // ~~~~~ ~~~~~~~~~~~~
  390. template <class T> class TDllLoader {
  391.   public:
  392.     TDllLoader();
  393.    ~TDllLoader();
  394.     static bool IsAvailable();
  395.     static T*   Dll();
  396.  
  397. #if 0
  398.  
  399.     static T*   Dll;
  400. #endif
  401.   private:
  402.     static T*&  DllPtrRef();
  403. };
  404.  
  405.  
  406. #if 0
  407.  
  408. //
  409. // One static pointer to the dll object, loaded on demand
  410. //
  411. template <class T> T* TDllLoader<T>::Dll = 0;
  412. #endif
  413.  
  414. //
  415. // Create a dynamic copy of the DLL object (i.e. an instance of T) if we
  416. // do not have one already...
  417. //
  418. template <class T> TDllLoader<T>::TDllLoader()
  419. {
  420.   T*& dll = DllPtrRef();
  421.   WARN(dll != 0, "Multiple copies of DllLoaders for DLL: " << *dll);
  422.   if (dll == 0) {
  423.     try {
  424.       dll = new T;
  425.     }
  426.     catch (...) {
  427.     }
  428.   }
  429. }
  430.  
  431. //
  432. // Delete the dll object when we go away to release the dll from memory
  433. //
  434. template <class T> TDllLoader<T>::~TDllLoader()
  435. {
  436. #if 0
  437.   delete Dll;
  438.   Dll = 0;
  439. #endif
  440.   T*& dll = DllPtrRef();
  441.   delete dll;
  442.   dll = 0;
  443. }
  444.  
  445. //
  446. // Load the dll on demand, returning true if it was loaded OK
  447. //
  448. template <class T> bool TDllLoader<T>::IsAvailable()
  449. {
  450.   static TDllLoader<T> ThisLoader;
  451.   return DllPtrRef() != 0;
  452. }
  453.  
  454. //
  455. //
  456. //
  457. template <class T> T* TDllLoader<T>::Dll()
  458. {
  459.   PRECONDITION(DllPtrRef() != 0);
  460.   return DllPtrRef();
  461. }
  462.  
  463. //
  464. // Method encapsulating single instance of pointer to DLL objecct
  465. //
  466. template <class T> T*& TDllLoader<T>::DllPtrRef()
  467. {
  468.   static T* ThisDll = 0;
  469.   return ThisDll;
  470. }
  471.  
  472. //
  473. // class TModuleProc
  474. // ~~~~~ ~~~~~~~~~~~
  475. // Base module proc class does inital binding. Throws an exception if it
  476. // cannot bind
  477. //
  478. class _OWLCLASS TModuleProc {
  479.   public:
  480.     TModuleProc(const TModule& module, const char far* id);
  481.  
  482.   protected:
  483.     FARPROC Proc;
  484. };
  485.  
  486. //
  487. // Derived template classes perform type-safe parameter passing on call.
  488. // Different class for each number of parameters, 'V' version for void return.
  489. //
  490.  
  491. //
  492. class TModuleProcV0 : public TModuleProc {
  493.   public:
  494.     TModuleProcV0(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  495.  
  496.     void operator ()() {
  497.       typedef void (far WINAPI* TProc)();
  498.       ((TProc)Proc)();
  499.     }
  500. };
  501.  
  502. //
  503. template <class R>
  504. class TModuleProc0 : public TModuleProc {
  505.   public:
  506.     TModuleProc0(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  507.  
  508.     R operator ()() {
  509.       typedef R (far WINAPI* TProc)();
  510.       return ((TProc)Proc)();
  511.     }
  512. };
  513.  
  514. //
  515. template <class P1>
  516. class TModuleProcV1 : public TModuleProc {
  517.   public:
  518.     TModuleProcV1(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  519.  
  520.     void operator ()(P1 p1) {
  521.       typedef void (far WINAPI* TProc)(P1 p1);
  522.       ((TProc)Proc)(p1);
  523.     }
  524. };
  525.  
  526. //
  527. template <class R, class P1>
  528. class TModuleProc1 : public TModuleProc {
  529.   public:
  530.     TModuleProc1(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  531.  
  532.     R operator ()(P1 p1) {
  533.       typedef R (far WINAPI* TProc)(P1 p1);
  534.       return ((TProc)Proc)(p1);
  535.     }
  536. };
  537.  
  538. //
  539. template <class P1, class P2>
  540. class TModuleProcV2 : public TModuleProc {
  541.   public:
  542.     TModuleProcV2(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  543.  
  544.     void operator ()(P1 p1, P2 a2) {
  545.       typedef void (far WINAPI* TProc)(P1 p1, P2 a2);
  546.       ((TProc)Proc)(p1, a2);
  547.     }
  548. };
  549.  
  550. //
  551. template <class R, class P1, class P2>
  552. class TModuleProc2 : public TModuleProc {
  553.   public:
  554.     TModuleProc2(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  555.  
  556.     R operator ()(P1 p1, P2 p2) {
  557.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2);
  558.       return ((TProc)Proc)(p1, p2);
  559.     }
  560. };
  561.  
  562. //
  563. template <class P1, class P2, class P3>
  564. class TModuleProcV3 : public TModuleProc {
  565.   public:
  566.     TModuleProcV3(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  567.  
  568.     void operator ()(P1 p1, P2 p2, P3 p3) {
  569.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3);
  570.       ((TProc)Proc)(p1, p2, p3);
  571.     }
  572. };
  573.  
  574. //
  575. template <class R, class P1, class P2, class P3>
  576. class TModuleProc3 : public TModuleProc {
  577.   public:
  578.     TModuleProc3(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  579.  
  580.     R operator ()(P1 p1, P2 p2, P3 p3) {
  581.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3);
  582.       return ((TProc)Proc)(p1, p2, p3);
  583.     }
  584. };
  585.  
  586. //
  587. template <class P1, class P2, class P3, class P4>
  588. class TModuleProcV4 : public TModuleProc {
  589.   public:
  590.     TModuleProcV4(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  591.  
  592.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4) {
  593.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4);
  594.       ((TProc)Proc)(p1, p2, p3, p4);
  595.     }
  596. };
  597.  
  598. //
  599. template <class R, class P1, class P2, class P3, class P4>
  600. class TModuleProc4 : public TModuleProc {
  601.   public:
  602.     TModuleProc4(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  603.  
  604.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4) {
  605.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4);
  606.       return ((TProc)Proc)(p1, p2, p3, p4);
  607.     }
  608. };
  609.  
  610. //
  611. template <class P1, class P2, class P3, class P4, class P5>
  612. class TModuleProcV5 : public TModuleProc {
  613.   public:
  614.     TModuleProcV5(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  615.  
  616.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
  617.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5);
  618.       ((TProc)Proc)(p1, p2, p3, p4, p5);
  619.     }
  620. };
  621.  
  622. //
  623. template <class R, class P1, class P2, class P3, class P4, class P5>
  624. class TModuleProc5 : public TModuleProc {
  625.   public:
  626.     TModuleProc5(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  627.  
  628.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
  629.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5);
  630.       return ((TProc)Proc)(p1, p2, p3, p4, p5);
  631.     }
  632. };
  633.  
  634. //
  635. template <class P1, class P2, class P3, class P4, class P5, class P6>
  636. class TModuleProcV6 : public TModuleProc {
  637.   public:
  638.     TModuleProcV6(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  639.  
  640.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
  641.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6);
  642.       ((TProc)Proc)(p1, p2, p3, p4, p5, p6);
  643.     }
  644. };
  645.  
  646. //
  647. template <class R, class P1, class P2, class P3, class P4, class P5, class P6>
  648. class TModuleProc6 : public TModuleProc {
  649.   public:
  650.     TModuleProc6(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  651.  
  652.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
  653.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6);
  654.       return ((TProc)Proc)(p1, p2, p3, p4, p5, p6);
  655.     }
  656. };
  657.  
  658. //
  659. template <class P1, class P2, class P3, class P4, class P5, class P6, class P7>
  660. class TModuleProcV7 : public TModuleProc {
  661.   public:
  662.     TModuleProcV7(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  663.  
  664.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
  665.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  666.                                        P7 p7);
  667.       ((TProc)Proc) (p1, p2, p3, p4, p5, p6, p7);
  668.     }
  669. };
  670.  
  671. //
  672. template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
  673.           class P7>
  674. class TModuleProc7 : public TModuleProc {
  675.   public:
  676.     TModuleProc7(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  677.  
  678.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
  679.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  680.                                     P7 p7);
  681.       return ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7);
  682.     }
  683. };
  684.  
  685. //
  686. template <class P1, class P2, class P3, class P4, class P5, class P6,
  687.           class P7, class P8>
  688. class TModuleProcV8 : public TModuleProc {
  689.   public:
  690.     TModuleProcV8(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  691.  
  692.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
  693.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  694.                                     P7 p7, P8 p8);
  695.       ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8);
  696.     }
  697. };
  698.  
  699. //
  700. template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
  701.           class P7, class P8>
  702. class TModuleProc8 : public TModuleProc {
  703.   public:
  704.     TModuleProc8(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  705.  
  706.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
  707.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  708.                                     P7 p7, P8 p8);
  709.       return ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8);
  710.     }
  711. };
  712.  
  713. //
  714. template <class P1, class P2, class P3, class P4, class P5, class P6,
  715.           class P7, class P8, class P9>
  716. class TModuleProcV9 : public TModuleProc {
  717.   public:
  718.     TModuleProcV9(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  719.  
  720.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) {
  721.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  722.                                     P7 p7, P8 p8, P9 p9);
  723.       ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
  724.     }
  725. };
  726.  
  727. //
  728. template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
  729.           class P7, class P8, class P9>
  730. class TModuleProc9 : public TModuleProc {
  731.   public:
  732.     TModuleProc9(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  733.  
  734.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) {
  735.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  736.                                     P7 p7, P8 p8, P9 p9);
  737.       return ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
  738.     }
  739. };
  740.  
  741. //
  742. template <class P1, class P2, class P3, class P4, class P5, class P6,
  743.           class P7, class P8, class P9, class P10>
  744. class TModuleProcV10 : public TModuleProc {
  745.   public:
  746.     TModuleProcV10(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  747.  
  748.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9,
  749.                   P10 p10) {
  750.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  751.                                     P7 p7, P8 p8, P9 p9, P10 p10);
  752.       ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
  753.     }
  754. };
  755.  
  756. //
  757. template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
  758.           class P7, class P8, class P9, class P10>
  759. class TModuleProc10 : public TModuleProc {
  760.   public:
  761.     TModuleProc10(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  762.  
  763.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9,
  764.                   P10 p10) {
  765.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  766.                                     P7 p7, P8 p8, P9 p9, P10 p10);
  767.       return ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
  768.     }
  769. };
  770.  
  771. //
  772. template <class P1, class P2, class P3, class P4, class P5, class P6,
  773.           class P7, class P8, class P9, class P10, class P11>
  774. class TModuleProcV11 : public TModuleProc {
  775.   public:
  776.     TModuleProcV11(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  777.  
  778.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9,
  779.                   P10 p10, P11 p11) {
  780.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  781.                                     P7 p7, P8 p8, P9 p9, P10 p10, P11 p11);
  782.       ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
  783.     }
  784. };
  785.  
  786. //
  787. template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
  788.           class P7, class P8, class P9, class P10, class P11>
  789. class TModuleProc11 : public TModuleProc {
  790.   public:
  791.     TModuleProc11(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  792.  
  793.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9,
  794.                   P10 p10, P11 p11) {
  795.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  796.                                     P7 p7, P8 p8, P9 p9, P10 p10, P11 p11);
  797.       return ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
  798.     }
  799. };
  800.  
  801. //
  802. template <class P1, class P2, class P3, class P4, class P5, class P6,
  803.           class P7, class P8, class P9, class P10, class P11, class P12>
  804. class TModuleProcV12 : public TModuleProc {
  805.   public:
  806.     TModuleProcV12(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  807.  
  808.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9,
  809.                   P10 p10, P11 p11, P12 p12) {
  810.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  811.                                     P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12);
  812.       ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12);
  813.     }
  814. };
  815.  
  816. //
  817. template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
  818.           class P7, class P8, class P9, class P10, class P11, class P12>
  819. class TModuleProc12 : public TModuleProc {
  820.   public:
  821.     TModuleProc12(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  822.  
  823.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9,
  824.                   P10 p10, P11 p11, P12 p12) {
  825.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  826.                                     P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12);
  827.       return ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12);
  828.     }
  829. };
  830.  
  831. //
  832. template <class P1, class P2, class P3, class P4, class P5, class P6,
  833.           class P7, class P8, class P9, class P10, class P11, class P12, class P13>
  834. class TModuleProcV13 : public TModuleProc {
  835.   public:
  836.     TModuleProcV13(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  837.  
  838.     void operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9,
  839.                   P10 p10, P11 p11, P12 p12, P13 p13) {
  840.       typedef void (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  841.                                     P7 p7, P8 p8, P9 p9, P10 p10, P11 p11,
  842.                                     P12 p12, P13 p13);
  843.       ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13);
  844.     }
  845. };
  846.  
  847. //
  848. template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
  849.           class P7, class P8, class P9, class P10, class P11, class P12, class P13>
  850. class TModuleProc13 : public TModuleProc {
  851.   public:
  852.     TModuleProc13(const TModule& module, const char far* id) : TModuleProc(module, id) {}
  853.  
  854.     R operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9,
  855.                   P10 p10, P11 p11, P12 p12, P13 p13) {
  856.       typedef R (far WINAPI* TProc)(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
  857.                                     P7 p7, P8 p8, P9 p9, P10 p10, P11 p11,
  858.                                     P12 p12, P13 p13);
  859.       return ((TProc)Proc)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13);
  860.     }
  861. };
  862.  
  863. //----------------------------------------------------------------------------
  864. // System DLL Wrapper
  865. //
  866.  
  867. #if defined(BI_PLAT_WIN16)
  868. # if !defined(LPCTSTR)
  869. #   define  LPCTSTR LPCSTR
  870. # endif
  871. # if !defined(LPTSTR)
  872. #   define  LPTSTR  LPSTR
  873. # endif
  874. #endif
  875.  
  876. //
  877. //
  878. //
  879. class _OWLCLASS TUser {
  880.   public:
  881.     static  HICON    LoadIcon(HINSTANCE, LPCTSTR);
  882.     static  BOOL     DestroyIcon(HICON);
  883.     static  BOOL     GetClassInfo(HINSTANCE, LPCTSTR, LPWNDCLASS);
  884.     static  int      GetMenuString(HMENU, UINT, LPTSTR, int, UINT);
  885.     static  UINT     GetMenuState(HMENU, UINT, UINT);
  886.     static  TModule& GetModule();
  887. };
  888.  
  889. // Generic definitions/compiler options (eg. alignment) following the
  890. // definition of classes
  891. #include <services/posclass.h>
  892.  
  893. #if defined(BI_NAMESPACE)
  894. } // namespace OWL
  895. #endif
  896.  
  897. //----------------------------------------------------------------------------
  898. // Inline implementation
  899. //
  900.  
  901. //
  902. // Return the name of the module.
  903. //
  904. inline const char far* TModule::GetName() const
  905. {
  906.   return Name;
  907. }
  908.  
  909. //
  910. // Return the instance handle of the library module represented by the
  911. // TModule obect.
  912. //
  913. inline TModule::THandle TModule::GetHandle() const
  914. {
  915.   return Handle;
  916. }
  917.  
  918. //
  919. // Operator returning the instance handle of the library module represented
  920. // by the TModule obect.
  921. //
  922. inline TModule::operator TModule::THandle() const
  923. {
  924.   return GetHandle();
  925. }
  926.  
  927. //
  928. // Return true if the handles of the modules are identical.
  929. //
  930. inline bool TModule::operator ==(const TModule& m) const
  931. {
  932.   return GetHandle() == m.GetHandle();
  933. }
  934.  
  935. //
  936. // Return true if the module has been successfully loaded.
  937. //
  938. inline bool TModule::IsLoaded() const
  939. {
  940.   return GetHandle() > HINSTANCE(HINSTANCE_ERROR);
  941. }
  942.  
  943.  
  944. #if defined(OWL2_COMPAT)
  945. //
  946. // Return the handle of the module.
  947. //
  948. inline TModule::THandle TModule::GetInstance() const
  949. {
  950.   return GetHandle();
  951. }
  952.  
  953. //
  954. // Set the handle of the module.
  955. //
  956. inline void TModule::SetInstance(TModule::THandle handle)
  957. {
  958.   SetHandle(handle);
  959. }
  960. #endif
  961.  
  962. #if defined(OWL1_COMPAT)
  963. //
  964. inline TWindow* TModule::ValidWindow(TWindow* win)
  965. {
  966.   return win;
  967. }
  968.  
  969. //
  970. inline bool TModule::LowMemory()
  971. {
  972.   return false;
  973. }
  974.  
  975. //
  976. inline void TModule::RestoreMemory()
  977. {
  978. }
  979. #endif
  980.  
  981. //
  982. // Return the full path of the location of the module.
  983. //
  984. inline int TModule::GetModuleFileName(char far* buff, int maxChars)
  985. {
  986.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  987.   return ::GetModuleFileName(Handle, buff, maxChars);
  988. }
  989.  
  990. //
  991. // Return the function address of a module.
  992. //
  993. inline FARPROC TModule::GetProcAddress(const char far* fcnName) const
  994. {
  995.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  996.   return ::GetProcAddress(Handle, fcnName);
  997. }
  998.  
  999. #if defined(BI_PLAT_WIN16)
  1000. //
  1001. // Retrieve the count of users on this module.
  1002. //
  1003. inline int TModule::GetModuleUsage() const
  1004. {
  1005.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1006.   return ::GetModuleUsage(Handle);
  1007. }
  1008.  
  1009. //
  1010. // Get the instance data.
  1011. //
  1012. inline int TModule::GetInstanceData(void NEAR* data, int len) const
  1013. {
  1014.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1015.   return ::GetInstanceData(Handle, (uint8 NEAR*)data, len);
  1016. }
  1017. #endif
  1018.  
  1019. //
  1020. // Wrapper for the Windows API to find a particular resource.
  1021. //
  1022. inline HRSRC TModule::FindResource(TResId id, const char far* type) const
  1023. {
  1024.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1025.   return ::FindResource(Handle, id, type);
  1026. }
  1027.  
  1028. //
  1029. // Wrapper for the Windows API.
  1030. //
  1031. inline HGLOBAL TModule::LoadResource(HRSRC hRsrc) const
  1032. {
  1033.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1034.   return ::LoadResource(Handle, hRsrc);
  1035. }
  1036.  
  1037. //
  1038. // Wrapper for the Windows API.
  1039. //
  1040. inline uint32 TModule::SizeofResource(HRSRC hRsrc) const
  1041. {
  1042.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1043.   return ::SizeofResource(Handle, hRsrc);
  1044. }
  1045.  
  1046. #if defined(BI_PLAT_WIN16)
  1047. //
  1048. // Wrapper for the Windows API.
  1049. //
  1050. inline int TModule::AccessResource(HRSRC hRsrc) const
  1051. {
  1052.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1053.   return ::AccessResource(Handle, hRsrc);
  1054. }
  1055.  
  1056. //
  1057. // Wrapper for the Windows API.
  1058. //
  1059. inline HGLOBAL TModule::AllocResource(HRSRC hRsrc, uint32 size) const
  1060. {
  1061.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1062.   return ::AllocResource(Handle, hRsrc, size);
  1063. }
  1064.  
  1065. //
  1066. // Wrapper for the Windows API.
  1067. //
  1068. inline RSRCHDLRPROC TModule::SetResourceHandler(const char far* type, RSRCHDLRPROC loadProc) const
  1069. {
  1070.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1071.   return ::SetResourceHandler(Handle, type, loadProc);
  1072. }
  1073. #endif
  1074.  
  1075. //
  1076. // Wrapper for the Windows API.
  1077. //
  1078. inline HBITMAP TModule::LoadBitmap(TResId id) const
  1079. {
  1080.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1081.   return ::LoadBitmap(Handle, id);
  1082. }
  1083.  
  1084. //
  1085. // Wrapper for the Windows API.
  1086. //
  1087. inline bool TModule::GetClassInfo(const char far* name, WNDCLASS far* wndclass) const
  1088. {
  1089.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1090.   return TUser::GetClassInfo(Handle, name, wndclass);
  1091. }
  1092.  
  1093. //
  1094. // Wrapper for the Windows API.
  1095. //
  1096. inline HACCEL TModule::LoadAccelerators(TResId id) const
  1097. {
  1098.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1099.   return ::LoadAccelerators(Handle, id);
  1100. }
  1101.  
  1102. //
  1103. // Wrapper for the Windows API.
  1104. //
  1105. inline HMENU TModule::LoadMenu(TResId id) const
  1106. {
  1107.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1108.   return ::LoadMenu(Handle, id);
  1109. }
  1110.  
  1111. //
  1112. // Wrapper for the Windows API.
  1113. //
  1114. inline HCURSOR TModule::LoadCursor(TResId id) const
  1115. {
  1116.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1117.   return ::LoadCursor(Handle, id);
  1118. }
  1119.  
  1120. //
  1121. // Wrapper for the Windows API.
  1122. //
  1123. inline HICON TModule::LoadIcon(const char far* name) const
  1124. {
  1125.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1126.   return ::LoadIcon(Handle, name);
  1127. }
  1128.  
  1129. #if defined(BI_PLAT_WIN16)
  1130. //
  1131. // Wrapper for the Windows API.
  1132. //
  1133. inline HCURSOR TModule::CopyCursor(HCURSOR hCursor) const
  1134. {
  1135.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1136.   return ::CopyCursor(Handle, hCursor);
  1137. }
  1138.  
  1139. //
  1140. // Wrapper for the Windows API.
  1141. //
  1142. inline HICON TModule::CopyIcon(HICON hIcon) const
  1143. {
  1144.   PRECONDITION(Handle > HINSTANCE(HINSTANCE_ERROR));
  1145.   return ::CopyIcon(Handle, hIcon);
  1146. }
  1147. #else
  1148.  
  1149. //
  1150. // Wrapper for the Windows API.
  1151. //
  1152. inline HICON TModule::CopyIcon(HICON hIcon) const
  1153. {
  1154.   return ::CopyIcon(hIcon);
  1155. }
  1156. #endif
  1157.  
  1158. //
  1159. // Return the version information about this module.
  1160. //
  1161. inline VS_FIXEDFILEINFO far& TModuleVersionInfo::GetFixedInfo()
  1162. {
  1163.   PRECONDITION(FixedInfo);
  1164.   return *FixedInfo;
  1165. }
  1166.  
  1167. //
  1168. inline uint32 TModuleVersionInfo::GetSignature() const
  1169. {
  1170.   PRECONDITION(FixedInfo);
  1171.   return FixedInfo->dwSignature;
  1172. }
  1173.  
  1174. //
  1175. inline uint32 TModuleVersionInfo::GetStrucVersion() const
  1176. {
  1177.   PRECONDITION(FixedInfo);
  1178.   return FixedInfo->dwStrucVersion;
  1179. }
  1180.  
  1181. //
  1182. // Get the major file version (first 32-bits).
  1183. //
  1184. inline uint32 TModuleVersionInfo::GetFileVersionMS() const
  1185. {
  1186.   PRECONDITION(FixedInfo);
  1187.   return FixedInfo->dwFileVersionMS;
  1188. }
  1189.  
  1190. //
  1191. // Get the minor file version (last 32-bits).
  1192. //
  1193. inline uint32 TModuleVersionInfo::GetFileVersionLS() const
  1194. {
  1195.   PRECONDITION(FixedInfo);
  1196.   return FixedInfo->dwFileVersionLS;
  1197. }
  1198.  
  1199. //
  1200. // Get the major product version number (first 32-bits).
  1201. //
  1202. inline uint32 TModuleVersionInfo::GetProductVersionMS() const
  1203. {
  1204.   PRECONDITION(FixedInfo);
  1205.   return FixedInfo->dwProductVersionMS;
  1206. }
  1207.  
  1208. //
  1209. // Get the minor product version number (last 32-bits).
  1210. //
  1211. inline uint32 TModuleVersionInfo::GetProductVersionLS() const
  1212. {
  1213.   PRECONDITION(FixedInfo);
  1214.   return FixedInfo->dwProductVersionLS;
  1215. }
  1216.  
  1217. //
  1218. // Return true if the flag has been set in the version info.
  1219. //
  1220. inline bool TModuleVersionInfo::IsFileFlagSet(uint32 flag) const
  1221. {
  1222.   PRECONDITION(FixedInfo);
  1223.   return (FixedInfo->dwFileFlagsMask & flag) && (FixedInfo->dwFileFlags & flag);
  1224. }
  1225.  
  1226. //
  1227. inline uint32 TModuleVersionInfo::GetFileFlagsMask() const
  1228. {
  1229.   PRECONDITION(FixedInfo);
  1230.   return FixedInfo->dwFileFlagsMask;
  1231. }
  1232.  
  1233. //
  1234. inline uint32 TModuleVersionInfo::GetFileFlags() const
  1235. {
  1236.   PRECONDITION(FixedInfo);
  1237.   return FixedInfo->dwFileFlags;
  1238. }
  1239.  
  1240. //
  1241. inline bool TModuleVersionInfo::IsDebug() const
  1242. {
  1243.   PRECONDITION(FixedInfo);
  1244.   return (FixedInfo->dwFileFlags & FixedInfo->dwFileFlagsMask & VS_FF_DEBUG) ?
  1245.          true : false;
  1246. }
  1247.  
  1248. //
  1249. inline bool TModuleVersionInfo::InfoInferred() const
  1250. {
  1251.   PRECONDITION(FixedInfo);
  1252.   return (FixedInfo->dwFileFlags & FixedInfo->dwFileFlagsMask & VS_FF_INFOINFERRED) ?
  1253.           true : false;
  1254. }
  1255.  
  1256. //
  1257. inline bool TModuleVersionInfo::IsPatched() const
  1258. {
  1259.   PRECONDITION(FixedInfo);
  1260.   return (FixedInfo->dwFileFlags & FixedInfo->dwFileFlagsMask & VS_FF_PATCHED) ?
  1261.           true : false;
  1262. }
  1263.  
  1264. //
  1265. inline bool TModuleVersionInfo::IsPreRelease() const
  1266. {
  1267.   PRECONDITION(FixedInfo);
  1268.   return (FixedInfo->dwFileFlags & FixedInfo->dwFileFlagsMask & VS_FF_PRERELEASE) ?
  1269.           true : false;
  1270. }
  1271.  
  1272. //
  1273. inline bool TModuleVersionInfo::IsPrivateBuild() const
  1274. {
  1275.   PRECONDITION(FixedInfo);
  1276.   return (FixedInfo->dwFileFlags & FixedInfo->dwFileFlagsMask & VS_FF_PRIVATEBUILD) ?
  1277.           true : false;
  1278. }
  1279.  
  1280. //
  1281. inline bool TModuleVersionInfo::IsSpecialBuild() const
  1282. {
  1283.   PRECONDITION(FixedInfo);
  1284.   return (FixedInfo->dwFileFlags & FixedInfo->dwFileFlagsMask & VS_FF_SPECIALBUILD) ?
  1285.           true : false;
  1286. }
  1287.  
  1288. // returns TFileOS values
  1289. inline uint32 TModuleVersionInfo::GetFileOS() const
  1290. {
  1291.   PRECONDITION(FixedInfo);
  1292.   return FixedInfo->dwFileOS;
  1293. }
  1294.  
  1295. //
  1296. inline TModuleVersionInfo::TFileType TModuleVersionInfo::GetFileType() const
  1297. {
  1298.   PRECONDITION(FixedInfo);
  1299.   return (TFileType)FixedInfo->dwFileType;
  1300. }
  1301.  
  1302. //
  1303. // Return the language id of this module.
  1304. //
  1305. inline uint TModuleVersionInfo::GetLanguage() const
  1306. {
  1307.   return uint(Lang);
  1308. }
  1309.  
  1310. //
  1311. // Return the language name of this module.
  1312. //
  1313. inline string TModuleVersionInfo::GetLanguageName() const
  1314. {
  1315.   return GetLanguageName(GetLanguage());
  1316. }
  1317.  
  1318. //
  1319. // Construct a TErrorMode object which invokes the 'SetErrorMode' API
  1320. // function to control how/whether Windows handles interrupt 24h errors.
  1321. //
  1322. inline TErrorMode::TErrorMode(uint mode)
  1323. {
  1324.   PrevMode = ::SetErrorMode(mode);
  1325. }
  1326.  
  1327. //
  1328. // Destructor of TErrorMode object - restore the state of the error mode
  1329. // saved during construction of the object.
  1330. //
  1331. inline TErrorMode::~TErrorMode()
  1332. {
  1333.   ::SetErrorMode(PrevMode);
  1334. }
  1335.  
  1336.  
  1337.  
  1338. //
  1339. // Get this header to get GetApplicationObject() for backward compatibility
  1340. // with Owl 2.0
  1341. //
  1342. #if defined(OWL2_COMPAT) && !defined(OWL_APPDICT_H)
  1343. # include <owl/appdict.h>
  1344. #endif
  1345.  
  1346. #endif  // OWL_MODULE_H
  1347.